<?php

namespace App\Models\V1;

use App\Scopes\V1\ValidDataScope;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class BasicCollectTransformers extends Model
{
    use SoftDeletes;

    protected $table = 'basic_collect_transformers';
    /**
     * 模型启动函数
     */
    protected static function boot()
    {
        parent::boot();
        static::addGlobalScope(new ValidDataScope);
    }

    /**
     * 可被批量赋值字段（白名单）
     *
     * @var array
     */
    protected $fillable = [
        'code','circuit_code','temperature','voltage','electric','process_state'
    ];

    /**
     * 限制数组或JSON输出时，隐藏字段
     *
     * @var array
     */
    protected $hidden = [
        'id','deleted_at',
    ];

    /**
     * 软删除，删除的时间字段
     * @var array
     */
    protected $dates = ['delete_at'];

    /**
     * 获取关联的回路信息
     *
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function circuit()
    {
        return $this->belongsTo(BasicCircuits::class,'circuit_code','code');
    }
}
